home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
UTIL
/
PRINTER
/
RISCRIPT
/
!RiScript
/
System
/
ErrHandler
next >
Wrap
Text File
|
1994-01-16
|
3KB
|
96 lines
%!
serverdict begin 0 exitserver
% Article 4903 of comp.lang.postscript:
% From: lhamey@mqccsunb.mqcc.mq.oz.au (Len Hamey)
% Newsgroups: comp.lang.postscript
% Subject: PostScript Error Dump Routine (free)
% Keywords: handleerror
% Message-ID: <432@macuni.mqcc.mq.oz>
% Date: 27 Aug 90 04:31:59 GMT
% Sender: news@macuni.mqcc.mq.oz
% Organization: Macquarie University, Sydney
% Lines: 74
% Whilst trying to determine why a particular PS file would not print,
% I developed the following error trap routine. I offer it to the net
% freely (you get what you pay for, usually). I would be interested
% in better/improved solutions to the same problem.
% Catch PS error and print out potentially useful info.
% If your PS code fails, just include this at start. Upon failure
% it dumps the current (incomplete) page then prints out two pages
% of error info.
% RvdB: Check for interactive input added -- 16/01/94
/ErrorStringBuffer 1000 string def
errordict /handleerror
{ showpage
% showpage also initializes graphics state.
/Times-Roman findfont 12 scalefont setfont
{
72 680 moveto
(Error encountered: ) show
$error /errorname get ErrorStringBuffer cvs show
72 660 moveto (Command in error: ) show
$error /command get ErrorStringBuffer cvs show
72 640 moveto
vmstatus (Virtual memory: max: ) show ErrorStringBuffer cvs show
( used: ) show ErrorStringBuffer cvs show
( level: ) show ErrorStringBuffer cvs show
72 600 moveto
(Context:) show
(\%stdin) (r) file bytesavailable 0 gt % non-interactive input only [RB]
{ 1 1 5
{ pop currentpoint 16 sub exch pop 108 exch moveto
(\%stdin) (r) file ErrorStringBuffer readline exch show
% Status_of_readline_false_if_end_of_file
not { exit } if
} for
} if
currentpoint 20 sub exch pop 72 exch moveto
(Execution Stack:) show
$error /estack get
length 1 sub % n-1
dup 100 sub dup % n-1 n-101 n-101
0 lt % n-1 n-101 n-101<0
{ 0 } { dup } ifelse % n-1 n-101 max(0,n-101)
exch pop -1 exch % n-1 -1 max(0,n-101)
{ currentpoint 16 sub exch pop 108 exch moveto
$error /estack get exch get ErrorStringBuffer cvs show
} for
} stopped pop
showpage
{
72 680 moveto
(Operand Stack:) show
$error /ostack get
length 1 sub % n-1
dup 100 sub dup % n-1 n-101 n-101
0 lt % n-1 n-101 n-101<0
{ 0 } { dup } ifelse % n-1 n-101 max(0,n-101)
exch pop -1 exch % n-1 -1 max(0,n-101)
{ currentpoint 16 sub exch pop 108 exch moveto
$error /ostack get exch get % Item from operand stack
dup type ErrorStringBuffer cvs show (: ) show
ErrorStringBuffer cvs show
} for
} stopped pop
showpage
} bind put
% The following is a test example of an error...
% 4 5 6 [1 2 3] (Fred was here) notandexistingoperator morebadstuff
% This is a line of text
% There is a little more
%% A comment line
% There follows more
% and more
% Len Hamey
% Macquarie University